{% extends 'base_index.html' %}

{% block title %}
    首页
{% endblock %}

{% block main %}
    <div class="nav">
        <div style="margin: 100px auto;display: flex;justify-content: space-around">
            <a href="/index/add/">添加新笔记</a>
        </div>

        {% if index_data.my_notes %}
            <table border="2" bordercolor="orange" cellpadding="5" cellspacing="2" align="center">
                <tr>
                    <th>标题</th>
                    <th>内容</th>
                    <th>创建时间</th>
                    <th>修改时间</th>
                    <th>作者</th>
                    <th>操作</th>
                </tr>
                {% for note in index_data.my_notes %}
                    <tr>
                        <td>{{ note.title }}</td>
                        <td>{{ note.content | truncatechars:6 }}</td>
                        <td>{{ note.create_time }}</td>
                        <td>{{ note.update_time }}</td>
                        <td>{{ note.user.username }}</td>
                        <td>
                            <a href="{% url 'index_update_note' note.id %}">修改</a>
                            <a href="{% url 'index_delete_note' note.id %}">删除</a>
                        </td>
                    </tr>
                {% endfor %}</table>
        {% endif %}
    </div>
{% endblock %}
